Backtrace Demo Backtrace is an OpenGL demo meant to simulate caustics like those produced by reverse ray tracing. The demo draws three spotlights whose light is refracted through a sphere. backtrace.tar.Z is a compressed tar file containing the backtrace source code. To select a light, click on it with the mouse. The lights are specified in spherical coordinates. Dragging with the left mouse button changes theta (the angle around the z axis). Dragging toward or away from the center of the window using the middle mouse button changes the radius, or the distance of the light from the sphere. Dragging with the right mouse button changes phi, or the inclination of the light. Note that chaging theta is very quick while chaning r or phi is slow -- this is because the shadows and caustics do not need to be recomputed if only theta changes. The pulldown menus may be used to change various parameters. The "Material" menu may be used to change the index of refraction of the sphere. The "Draw" menu turns the drawing of various portions of the scene on and off. The "Subdivision" menu changes the tessellation of the square, shadows, caustics and sphere. Use the "Lights" menu to turn lights on and off. Under the "Motion" menu, the "Quick Motion" option halts recomputation of shadows until after the mouse button is released. The "Rotate Automatically" button sets the lights rotating independently about the z axis for a non-interactive demo. The elements of the scene are drawn in a variety of ways. The floor is drawn as a triangular mesh illuminated by three spotlights. Next the shadows are drawn without enabling the zbuffer. They are drawn by setting the color mask to correspond to the color of the light which is casting the shadow so that they will not interfere with the components of the color created by the other light sources. The shadow is drawn in the scene's ambient color. Shadows are precomputed as disks projected from the location of the sphere through the light's location into the xy plane. The refractions are projected in the same way, except the direction of the projection is modified to take into account the index of refraction of the material. The intensity of the light in the refraction is computed using the difference in the area of a section between the shadow and the refraction. For example, if a given section has an area of 1 in the shadow and an area of 1.3 in the refraction, the intensity of the light used when drawwing the refraction is 1.3 times the intensity used when drawing that section of the shadow. In other words, a given quantity of light appears brighter if it is spread over a smaller area. The caustics are drawn using blending functions. The three-dimensional objects used to draw the light sources are drawn next using two-sided lighting so that the inside and the outside appear to be lit differently. Next the image of the scene as viewed through the sphere is drawn. An image of the sphere is drawn into the stencil plane. Stenciling is enabled and the scene is re-rendered using a larger field of view, which makes objects appearing through the sphere look smaller. The sphere itself is drawn as a rather hacked lit disk which is more transparent in the center than around the edges. This allows the sphere to look as though it has some substance. old backtrace README stuff ABOUT THIS PROGRAM: Backtrace is an OpenGL program meant to simulate ray tracing. It displays a refractive sphere above a plane. The sphere is lit by red, green, and blue spotlights which may be manually moved. The shadow of the sphere and the light which is refracted through the sphere are projected onto the plane. The "Material" menu controls the refractiveness of the sphere. The "Draw" menu controls which subparts of the scene are drawn. By default, the "Draw Texture" option is off. Texture mapping is slow on many systems and the texture map is completely gratuitous. However, you may want to turn texture mapping on once to see if the performance is acceptable on your system. The "Subdivision" menu controls the number of subdivisions used to draw the plane, the sphere, the lights, the shadows, and the refractions. More subdivisions will look better, but will be slower. The "Lights" menu can be used to turn the lights on and off on an individual basis. The "Reset Lights" button moves all the lights back to their original positions. The "Quick Motion" option under the option menu makes motions in r and phi (controlled by the middle and right mouse buttons, respectively) happen much more quickly by delaying recompuation of the shadows and refraction until the mouse button is released. The "Rotate Automatically" toggle causes the lights to rotate about the z axis at random speeds. Moving of the lights is accomplished with the mouse. The author wishes to apologize for the horribly awkward interface. To move a light, move the pointer over it and press one of the mouse buttons down. Draw the mouse to move the light. It is easiest to imagine the lights in spherical coordinates. The left mouse button controls rotation in theta (about the z axis). Moving the mouse horizontally while holding down the left mouse button will increase or decrease theta. The middle mouse button controls the radius, or the distance of the light from the sphere. Dragging the mouse toward the center of the screen decreases the distance of the light from the sphere, while moving away from the center of the screen increases the distance. The right mouse button controls rotation in phi, which can be thought of as the elevation of the light. Moving the mouse horizontally will change the elevation. TO COMPILE: If you have not already done so, copy all files from the CDROM to a directory on your computer. First, run the shell script UNCAP to get everything back from upper case letters. Type "make." Note that you must have a C++ compiler installed. There may be a warning or two, but these should not cause problems. You must first have compiled libGLw.a and libtk.a. You must also have a development copy of Motif installed. OTHER MAKEFILE TARGETS: "make clean" removes objects, ~ files, and core files. "make clobber" also removes the executable. KNOWN BUGS: It's possible to change the phi of a light in such a way that the light gets below the sphere, which leads to unexpected (and inaccurate) results. AUTHOR: Celeste Fowler
Source
Documentation
Reference
Subdirectories